package com.proj.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.jws.WebParam;

@Controller
@RequestMapping("/user")
public class LoginController {

    @ResponseBody
    @RequestMapping("/hello")
    public String hello(){
        return  "Hello 211 spring boot hello world";
    }

    @RequestMapping("/doLogin")
    public String toIndex(){
        //springboot 内置的模板不支持 jsp,如果要是用jsp,则需要再pom文件中手动导入,tomcat jsp支持,jstl  ,servlet
        return "login"; //视图解析器 默认匹配 resources>templates>login.html >>前缀  / 后缀
    }

    @RequestMapping("/toAdmin")
    public String toAdmin(Model model){
        System.out.println("----------------toAdmin");
        model.addAttribute("username","t211admin");
        return "admin";  //视图解析器  去" src\main\webapp\WEB-INF\jsp"  找 admin.jsp
    }
}
